/*
 * @Author: jiu yin
 * @Date: 2024-06-13 16:32:37
 * @LastEditTime: 2024-06-17 15:32:23
 * @LastEditors: jiu yin zhen jing
 * @FilePath: \studio-web-admin\src\view\problem\index.tsx
 * jiu
 */
import { faq_list } from "@/api/home";
import { Badge, Pagination, Tabs } from "antd";
import { useEffect, useState } from "react";
import "./index.scss";
import { ClearOutlined } from "@ant-design/icons";
import { useRoute } from "@/hooks";

export default function index() {
	let { push } = useRoute();

	//Badge 状态 1未读 2已读
	const Badge_status = (status: number) => {
		return <Badge status={status==1 ? "processing" : "default"} />;
	};
	let [faq_list_data, setFaq_list_data] = useState<any>([]);

	//分页
	let [params, set_params] = useState({ page: 1, total: 100 });
	useEffect(() => {
		faq_list({ page: params.page, limit: 10 }).then((res: any) => {
			setFaq_list_data(res.data.data);
			set_params({ ...params, total: res.data.total });
		});
	}, [params.page]);
	return (
		<section className="ml-auto mr-auto w-920px">
			<ul className="mt-13px pr-20px message_ul c-#161940">
				{faq_list_data.map((item: any, index: number) => (
					<li
						key={index}
						onClick={() => push("/problem/detail?question_id=" + item.question_id)}
						className="h-60px flex items-center justify-between text-14px cursor-pointer border_li_bottom message_li">
						<div className="flex items-center">
							{Badge_status(0)}
							<p className=" font-700 ml-16px">{item.question_name}</p>
						</div>
						<p className="c-#9697A9">{item.created_at}</p>
					</li>
				))}
			</ul>
			<section className="flex justify-center mt-20px">
				<Pagination
					defaultCurrent={1}
					total={params.total}
					hideOnSinglePage={true}
					showSizeChanger={false}
					onChange={e => set_params({ ...params, page: e })}
				/>
			</section>
		</section>
	);
}
